# 获取script的src
getScriptSrc = (s) -> if s.hasAttribute then s.src else s.getAttribute('src',4)

# loader 节点
jsNode = (->
    ns = document.getElementsByTagName("script")
    n = ns[ns.length - 1]
    for s in ns
        if getScriptSrc(s).indexOf('/res/loader') > 0
            n = s
            break
    n
)()

# 资源路径
resPath = getScriptSrc(jsNode).replace(/[^\/]+$/,'')

document.write """
    <link href="#{resPath}css/highlight-xcode.css" rel="stylesheet" type="text/css" />
    <link href="#{resPath}css/main.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="#{resPath}script/highlight.js?_v1"></script>
    <script type="text/javascript" src="#{resPath}sky_v2/sky.js?_v1"></script>
"""

window.onload = -> hljs.initHighlighting()